<%@ page contentType="text/html;charset=UTF-8" %>
<html>
	<head>
		<title>ajax上传文件</title>
		<script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
		<script src="/js/ajaxfileupload.js"></script>
	</head>
<body>
	<div>
		<div style="width:100px;height:100px;overflow:hidden;">
			<img src="" id="img" />
		</div>
		<input type="file" name="uFile"  id="uFile" value="上传文件" onchange="upload();" />
	</div>
	<script type="text/javascript">
		function upload(){
	        $.ajaxFileUpload
	        (
	                {
	                    url: "upload",
	                    type:'post',
	                    secureuri: false, //是否需要安全协议，一般设置为false
	                    fileElementId: 'uFile', //文件上传域的ID
	                    dataType: 'json', //返回值类型 一般设置为json
	                    success: function(data){
	                    	console.log(data)
	                    	$('#img').attr('src',data.path);
	                    },
	                    error:function(data, status, e){
	                    	alert('bb')
	                    }
	                }
	        )
		}
	</script>
</body>
</html>
